/* // 封装request请求
import axios from "axios"
// import cookies from 'vue-cookies'

axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'

// 创建axios实例
const service = axios.create({
    baseURL: process.env.VUE_APP_BASE_API,
    timeout: 10000
})
// request拦截器
service.interceptors.request.use(config => {
    return config
}, err => {
    console.log("出错了" + err);
    Promise.reject(err)
})

// 响应拦截器
service.interceptors.response.use(res => {
    // 未设置状态码则默认成功状态
    // const code = res.data.code || 200;
    console.log(res)
    // // 获取错误信息
    // const message = res.data.msg
    // console.log(code + " ====  " + message)
}, error => { console.log('err====' + error) }
)

export default service */

// 导入axios
import axios from 'axios';

//axios.defaults.baseURL = 'http://localhost:8080/';
// 请求响应超时时间
axios.defaults.timeout = 50000;

// 封装自己的get/post方法
export default {
  get: function(path = '', data = {}) {
    return new Promise(function(resolve, reject) {
      axios.get(path, {
        params: data
      })
        .then(function(response) {
          // 按需求来，这里我需要的是response.data，所以返回response.data，一般直接返回response
          resolve(response.data);
        })
        .catch(function(error) {
          reject(error);
        });
    });
  },
  post: function(path = '', data = {}) {
    return new Promise(function(resolve, reject) {
      axios.post(path, data)
        .then(function(response) {
          resolve(response.data);
        })
        .catch(function(error) {
          reject(error);
        });
    });
  }
};
